package com.kaoshi.management.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kaoshi.common.config.Result;
import com.kaoshi.management.pojo.XtPermissions;
import com.kaoshi.management.pojo.XtRoles;
import com.kaoshi.management.service.XtRolesService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;


import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-07
 */
@RestController
@CrossOrigin
@RequestMapping("/xt-roles")
public class XtRolesController {
    @Autowired
    private XtRolesService xtRolesService;



    // 获取所有角色
    @PostMapping("/all/{current}/{pageSize}")
    public Result findAll(@PathVariable Integer current,
                          @PathVariable Integer pageSize,
                          @RequestBody XtRoles xtRoles) {

        Page<XtRoles> page = xtRolesService.getPageList(current, pageSize,xtRoles);
        return Result.ok(page);
    }

    // 添加或修改角色
    @PostMapping("/change")
    public Result change(@RequestBody XtRoles role) {
        XtPermissions permissions = new XtPermissions();
            // 新增角色

            xtRolesService.save(role);
        return Result.ok("角色添加成功");
        }

}


